# -*- coding: utf-8 -*-
<%!
    from toscawidgets.core import Widget
%>

{
<%sep = ''%>

%for param in params-frozenset(['c', 'parent', 'css_class','css_classes', 'children', 'root','obj','id','params']):
<% 	__x=obj
	p = eval('obj.'+param) 
%>

%if p!=None:
	
	%if param=='componentId':
		${sep}id :'${p}'
	%elif param in ['layoutConfig','columnWidth','defaults','anchor']:
		%if p != '':
			${sep}${param} : ${p}
		%endif
	%elif param=='tbar':
		${sep}tbar : new Ext.Toolbar(${p.display(value_for(p), **args_for(p))})
	%elif isinstance(p,str) or isinstance(p,unicode):
		%if param in ['applyTo']:
			%if p!='':
				${sep+param} :'${p}'
			%endif
		%else:
			${sep+param} :'${p}'
		%endif
	%elif isinstance(p,bool):
		${sep+param} : ${str(p).lower()}
	%elif isinstance(p,Widget):
		${sep+param} : ${p.display(value_for(p), **args_for(p)) }
	%elif param=='handlers':
		%if len(p)==0:
			<% continue %>
		%endif
		%for handler in p:
			<%sep2 = ''%>
			${sep+handler.name} : function(
				%for arg in handler.args:
					${sep2+arg}
					<% sep2 = ',' %>
				%endfor
				){
					${handler.body}
				}
		%endfor
	%elif isinstance(p,list) and len(p)>0 :
		${sep+param} : [
		<%sep1 = ''%>
		%for item in p:
			${sep1+item.display(value_for(item), **args_for(item)) }
			<% sep1 = ',' %>
		%endfor
		]
	%else: 
		${sep+param} :${p}		
	%endif
	
	<% sep = ',' %>
%endif
	
%endfor 

}